from numpy import array, linspace, append
import feapy

x = linspace(0.0, 0.25, 3)
y = linspace(0.0, 1.5, 5)

mydomain = feapy.domain.Domain()

node_id = 1
for i in range(y.size):
    for j in range(x.size):
        mydomain.add_node(feapy.node.Node(node_id, 2, \
                                     coordinates=array([x[j], y[i]])))
        mydomain.nodes[node_id].print_nodal_coordinates()
        node_id += 1

e1 = feapy.element.FourNodeQuad(1, element_node_ids=[1, 2, 4, 5])
e2 = feapy.element.FourNodeQuad(2, element_node_ids=[2, 3, 5, 6])
e3 = feapy.element.FourNodeQuad(3, element_node_ids=[4, 5, 7, 8])
e4 = feapy.element.FourNodeQuad(4, element_node_ids=[5, 6, 8, 9])
e5 = feapy.element.FourNodeQuad(5, element_node_ids=[7, 8, 10, 11])
e6 = feapy.element.FourNodeQuad(6, element_node_ids=[8, 9, 11, 12])
e7 = feapy.element.FourNodeQuad(7, element_node_ids=[10, 11, 13, 14])
e8 = feapy.element.FourNodeQuad(8, element_node_ids=[11, 12, 14, 15])

mydomain.add_element(e1)
mydomain.add_element(e2)
mydomain.add_element(e3)
mydomain.add_element(e4)
mydomain.add_element(e5)
mydomain.add_element(e6)
mydomain.add_element(e7)
mydomain.add_element(e8)

for element_id in mydomain.elements:
    mydomain.elements[element_id].print_debug_info()

c1 = feapy.constraint.SPConstraint(1, 1, 1, 0.0)
c2 = feapy.constraint.SPConstraint(2, 10, 1, 0.0)
c3 = feapy.constraint.SPConstraint(3, 1, 2, 0.0)
c4 = feapy.constraint.SPConstraint(4, 3, 2, 0.0)

mydomain.add_sp_constraint(c1)
mydomain.add_sp_constraint(c2)
mydomain.add_sp_constraint(c3)
mydomain.add_sp_constraint(c4)

for constraint_id in mydomain.sp_constraints:
    mydomain.sp_constraints[constraint_id].print_debug_info()
# Add 6 four-node-quad elements.

#print mydomain.nodes[n+1].coordinates.size
#
#lengths = array([])
#area = 10.0
#youngs_modulus = 30e6

#for n in range(1,x.size):
#    length = x[n] - x[n-1]
#    element_nodes = [mydomain.nodes[n], mydomain.nodes[n+1]]
#    r = RodElement(n, youngs_modulus, area, length, element_nodes)
#    mydomain.add_element(r)

#for element_id in mydomain.elements:
#    mydomain.elements[element_id].print_debug_info()
